package com.yy.wga.mp.module.user.controller;


import com.yy.wga.common.core.dto.Result;
import com.yy.wga.mp.common.interceptor.RequestUserHolder;
import com.yy.wga.mp.module.user.response.UserRelationSubCountResponse;
import com.yy.wga.mp.module.user.service.UserRelationService;
import com.yy.wga.user.feign.api.UserRelationSummaryFeign;
import com.yy.wga.user.feign.request.UserRelationSubCountRequest;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 用户粉丝数据汇总
 *
 * @author guochao
 * @since 2025-01-04 18:34:28
 */
@RestController
@RequestMapping("api/user/relationSummary")
public class UserRelationSummaryController {
    /**
     * 服务对象
     */
    @Resource
    private UserRelationSummaryFeign userRelationSummaryFeign;
    @Resource
    private UserRelationService userRelationService;

    /**
     * 获取下级粉丝数量
     * @return
     */
    @PostMapping("subFansCount")
    public Result<UserRelationSubCountResponse> subFansCount() {
        UserRelationSubCountRequest request = new UserRelationSubCountRequest();
        request.setUserId(RequestUserHolder.getUserCache().getUserId());
        Result<com.yy.wga.user.feign.response.UserRelationSubCountResponse> summaryResult = userRelationSummaryFeign.subFansCount(request);
        if (!summaryResult.isSuccess()) {
            return Result.fail(summaryResult.getMessage());
        }
        return Result.success(com.yy.wga.common.utils.mapping.BeansUtils.map(summaryResult.getData(), UserRelationSubCountResponse.class));
    }
}
